/*
 * Copyright 2011 Impetus Infotech.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.impetus.teamplan;

import java.util.Calendar;

/**
 * @author amresh.singh
 *
 */
public class PlanMonth {
	private String month;
	private String year;
	
	
	public PlanMonth(String month, String year) {
		this.month = month;
		this.year = year;
	}
	/**
	 * @return the month
	 */
	public String getMonth() {
		return month;
	}
	/**
	 * @param month the month to set
	 */
	public void setMonth(String month) {
		this.month = month;
	}
	/**
	 * @return the year
	 */
	public String getYear() {
		return year;
	}
	/**
	 * @param year the year to set
	 */
	public void setYear(String year) {
		this.year = year;
	}
	
	public static PlanMonth getCurrentMonth() {		
		Calendar cal = Calendar.getInstance();		
		String currentMonth = "" + cal.get(Calendar.MONTH);
		String currentYear = "" + cal.get(Calendar.YEAR);
		currentMonth = currentMonth.length() == 1 ? "0" + currentMonth : currentMonth; 
		System.out.println("Current Month:" + currentMonth + ";Current Year:" + currentYear);
		
		return new PlanMonth(currentMonth, currentYear);
		
	}
	
	public static PlanMonth getNextMonth(String currentMonth, String currentYear) {
		String nextMonth = new String(currentMonth);
		String nextYear = new String(currentYear);
		
		if(Integer.parseInt(nextMonth) == 11) {
			nextMonth = "00";
			nextYear = "" + (Integer.parseInt(nextYear) + 1);
		} else {
			nextMonth = "" + (Integer.parseInt(nextMonth) + 1);
			nextMonth = nextMonth.length() == 1 ? "0" + nextMonth : nextMonth;
		}
		
		System.out.println("nextMonth: " + nextMonth + ";nextYear:" + nextYear);
		return new PlanMonth(nextMonth, nextYear);
	}
	

}
